//
//  TwoLabelView.m
//  HuaRun2
//
//  Created by admin on 17/8/29.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import "TwoLabelView.h"

@interface TwoLabelView ()

@property (nonatomic, strong) UIView * backView;

@end

@implementation TwoLabelView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
#pragma mark - life cycle
- (void)dealloc {
    NSLog(@"%@ dealloc", [self class]);
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self viewInit];
        [self layoutInit];
    }
    return self;
}

- (void)viewInit {
    self.backgroundColor = RGBA(249, 249, 249, 1);
    
    [self addSubview:self.backView];
    [self addSubview:self.nameLab];
    [self addSubview:self.companyLab];
    
}

- (void)layoutInit {
    weakself(ws);
    
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws).offset(kMargin10);
        make.right.mas_equalTo(ws).offset(-kMargin10);
        make.top.mas_equalTo(ws).offset(0);
        make.bottom.mas_equalTo(ws);
    }];

    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws).offset(kMargin10 *2);
        make.top.mas_equalTo(ws).offset(kMargin10);
        make.right.mas_equalTo(ws.mas_right).offset(-kMargin10);
    }];
    
    [self.companyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.nameLab);
        make.top.mas_equalTo(ws.nameLab.mas_bottom).offset(kMargin10 / 2);
        make.right.mas_equalTo(ws.nameLab);
    }];
    
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(ws);
        make.size.mas_equalTo(CGSizeMake(kMainScreenWidth, 60));
    }];

}

#pragma mark - getter

- (UILabel *)nameLab {
    if (!_nameLab) {
        self.nameLab = [UILabel new];
        _nameLab.textAlignment = NSTextAlignmentLeft;
        _nameLab.font = kFontSize15;
        _nameLab.textColor = [UIColor colorWithHex:@"3c3c3c"];
    }
    return _nameLab;
}

- (UILabel *)companyLab {
    if (!_companyLab) {
        self.companyLab = [UILabel new];
        _companyLab.textAlignment = NSTextAlignmentLeft;
        _companyLab.font = kFontSize15;
        _companyLab.textColor = [UIColor colorWithHex:@"3c3c3c"];
    }
    return _companyLab;
}

- (UIView *)backView {
    if (!_backView) {
        self.backView = [UIView new];
        _backView.backgroundColor = [UIColor whiteColor];
    }
    return _backView;
}
@end
